package stackAndQueue;

public class Queue {

}


class MyQueue {
	public static int MAX = 101;
	public static int[] stackPush = new int[MAX];
	public static int pushSize;
	public static int[] stackPop = new int[MAX];
	public static int popSize;
    public MyQueue() {
    	pushSize = popSize = 0;
    }
    private static void pushToPop() {
    	//输出栈为空， 则执行
    	if(popSize==0) {
    		//倒入数据
    		while(pushSize>0) {
    			stackPop[popSize++] = stackPush[--pushSize];
    		}
    	}
    }
    public void push(int x) {
    	stackPush[pushSize++] = x;
    	pushToPop();
    }
    
    public int pop() {
    	int ret = stackPop[--popSize];
    	pushToPop();
    	return ret;
    }
    
    public int peek() {
    	return stackPop[popSize-1];
    }
    
    public boolean empty() {
    	return pushSize == 0 && popSize == 0;
    }
}